home *** CD-ROM | disk | FTP | other *** search
- # Test List module.
- # Draw a window with all the files in the current folder.
- # double-clicking will change folder.
- #
- # This test expects Win, Evt and FrameWork (and anything used by those)
- # to work.
-
- import FrameWork
- import os
-
- def filllist(l):
- """Fill the list with the contents of the current directory"""
- l.DoDraw(0)
- l.DelRow(0)
- contents = os.listdir(':')
- l.AddRow(len(contents), 0)
- for i in range(len(contents)):
- l.SetCell(contents[i], (i, 0))
- l.DoDraw(1)
-
- class TestList(Application):
- def __init__(self):
- self.makemenubar()
- self.makewindow()
-
- def makewindow(self):
- r = (40, 40, 400, 300)
- w = Win.NewWindow(r, "List test", 1, 0, -1, 1, 0x55555555)
- r2 = (0, 0, 360, 260)
- self.list = List.LNew(r2, (0, 0, 0, 0), (0,0), 0, w, 0, 1, 1, 1)
- filllist(self.list)
-
- def makeusermenus(self):
- self.filemenu = m = Menu(self.menubar, "File")
- self.quititem = MenuItem(m, "Quit", "Q", self.quit)
-
- def quit(self, *args):
- raise self
-
- def do_about(self, id, item, window, event):
- EasyDialogs.Message("""Test the List Manager interface.
- Double-click on a folder to change directory""")
-
- def do_update(self, *args):
- self.list.LUpdate()
-
- def do_inContent(self, partcode, window, event):
- (what, message, when, where, modifiers) = event
- local = GlobalToLocal(where)
- dclick = self.list.LClick(local, modifiers)
- if dclick:
- h, v = self.list.LLastClick()
- file = self.list.LGetCell(1000, (h, v))
- os.chdir(file)
- filllist(self.list)
-
- def main():
- App = TestList()
- App.mainloop()
-
- if __name__ == '__main__':
- main()
-
-